package com.northpool.stpclient.demo;

import com.northpool.resources.datasource.IDataSource;
import com.northpool.resources.datasource.db.DbDataSource;
import com.northpool.resources.datatable.IField;
import com.northpool.resources.datatable.ITable;
import com.northpool.resources.datatable.SpatialInfo;

import java.util.Map;

public class TableMetaDemo {
    public static IDataSource createPGDataSource_kjklz() {
        String url = "127.0.0.1:5432/bcgtest";
        com.northpool.resources.Constants.DATA_SOURCE_TYPE type = com.northpool.resources.Constants.DATA_SOURCE_TYPE.postgreSQL;
        String user = "postgres";
        String password = "postgres";
        return new DbDataSource(url, user, password, type);
    }
    public static void main(String[] args) throws Exception {
        IDataSource ds = createPGDataSource_kjklz();
        ITable table = ds.getTable("table1");

        Map<String, IField> fieldsMap = table.getFieldsMap();
        for (IField value : fieldsMap.values()) {
            if(value.isPK()) {

            }else if(value.isSpatial()) {

            }
        }
        SpatialInfo spatialInfo = table.spatialInfo();
        Integer srid = spatialInfo.getSrid();
        if(!srid.equals(4490)) {
            System.out.println("非4490");
        }

    }
}
